package com.example.demo.service.impl;

import com.example.demo.model.purchaseMain;
import com.example.demo.repository.purchaseMainRepository;
import com.example.demo.service.purchaseMainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
@Transactional
@Service
public class purchaseMainServiceImpl implements purchaseMainService {
    @Resource
    private purchaseMainRepository puMainRepository;

    @Override
    public purchaseMain findById(String id) {
        return puMainRepository.findById(id).get();
    }

    @Override
    public List<purchaseMain> findAll() {
        return puMainRepository.findAll();
    }

    @Override
    public void delete(String id) {
        puMainRepository.deleteById(id);
    }
    @Override
    public void deleteAllByPmpriceIsNull()
    {
        puMainRepository.deleteAllByPmpriceIsNull();
    }
    @Override
    public purchaseMain save(purchaseMain purchaseMain) {
        return puMainRepository.save(purchaseMain);
    }
}
